package com.qf.service.impl;

import com.qf.dao.QueryConditionsMapper;
import com.qf.pojo.Discipline;
import com.qf.pojo.Grade;
import com.qf.pojo.response.BaseResult;
import com.qf.service.QueryConditionsService;
import com.qf.utils.CookieUtils;
import com.qf.utils.JWTUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class QueryConditionsServiceImpl implements QueryConditionsService {

    @Autowired
    private QueryConditionsMapper queryConditionsMapper;

    @Autowired
    private CookieUtils cookieUtils;

    @Autowired
    private JWTUtils jwtUtils;

    @Override
    public BaseResult findAllGrade() {
        BaseResult baseResult = new BaseResult();
        List<Grade> allGrade = queryConditionsMapper.findAllGrade();
        baseResult.setCode(200);
        baseResult.setData(allGrade);
        return baseResult;
    }


    @Override
    public BaseResult findAllSubject(Integer id) {
        BaseResult result = new BaseResult();
        List<Discipline> allSubject = queryConditionsMapper.findAllSubject(id);
        for (Discipline discipline : allSubject) {

        }
        result.setCode(200);
        result.setData(allSubject);
        return result;
    }

    @Override
    public BaseResult findMayCurse(HttpServletRequest request) {
        BaseResult result = new BaseResult();
        String token = cookieUtils.getToken(request.getCookies());

        return null;

    }
}
